#!/bin/bash

files=`ls ./temp`
for f in $files 
do
    file_name=`echo $f | awk -F '.' '{ print $1 }'`
    file_type=`echo $f | awk -F '.' '{ print $2 }'`
    echo "file name: $file_name, file type: $file_type"

    if [ "$file_type" != "webp" ]; then
        continue
    fi

    png_name="./temp/$file_name.png"
    if [ -f $png_name ]; then
        rm -rf $png_name
    fi
    
    src_path="./temp/$f"
    dwebp $src_path -o $png_name
done
